/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _VIEWPORTDIRECTDRAW_H_
#define _VIEWPORTDIRECTDRAW_H_

#include "RenderMethodDirectDraw.h"

#include "YGViewport.h"

namespace YoghurtGum
{

	class ViewportDirectDraw : public Viewport
	{

	public:

		ViewportDirectDraw(uint32 a_Width, uint32 a_Height, uint32 a_Type = YG_VIEWPORT_DEFAULT);
		~ViewportDirectDraw();

		void Resize(uint32 a_Width, uint32 a_Height);

		void SetType(uint32 a_Type);

		void SetX(real32 a_X);
		void SetY(real32 a_Y);
		void SetPosition(real32 a_X, real32 a_Y);
		void Move(real32 a_SpeedX, real32 a_SpeedY);

		void SetTargetPosition(uint32 a_X, uint32 a_Y);
		void SetDimensions(uint32 a_Width, uint32 a_Height);

		bool Enable();
		bool Disable();

		void SetBounds(Vec2 a_Dim);
		Vec2 GetScreenPosition(Vec2 a_WorldPos);
		Vec2 GetCenterPosition(Vec2 a_WorldPos);
		void SetWorldDimensions(uint32 a_Width, uint32 a_Height);

		void SetTarget(LPDIRECTDRAWSURFACE a_Surface) { m_TargetSurface = a_Surface; }
		LPDIRECTDRAWSURFACE GetBuffer() { return m_Surface; }
		RECT GetDimensions() { return m_Dimensions; }

	private:

		RECT m_Dimensions, m_Target;
		uint32 m_OffsetX, m_OffsetY;
		uint32 m_WorldX, m_WorldY;
		uint32 m_CenterX, m_CenterY;
		Vec2 m_Bounds;

		DDSURFACEDESC m_Settings;
		uint32 m_Properties;
		LPDIRECTDRAWCLIPPER m_Clipper;
		LPDIRECTDRAWSURFACE m_Surface;

		LPDIRECTDRAWSURFACE m_TargetSurface;
		
	}; // class ViewportDirectDraw

}; // namespace YoghurtGum

#endif